<?php
	//引入文件上传
	include_once('file.php');
	include_once('thumb.php');

  // // 判断是否有提交
if(!empty($_POST)){
	// print_r($_FILES);die;
		//调用图片上传函数-------------------------------------
		$savePath = '';
		if(!empty($_FILES['file']['name'][0])){
			$filelist = array();
			//数组重组
			foreach ($_FILES['file']['name'] as $key => $v) {
				$filelist[$key]['name'] = $v;
				$filelist[$key]['type'] = $_FILES['file']['type'][$key];
				$filelist[$key]['tmp_name'] = $_FILES['file']['tmp_name'][$key];
				$filelist[$key]['error'] = $_FILES['file']['error'][$key];
				$filelist[$key]['size'] = $_FILES['file']['size'][$key];
			}
			foreach ($filelist as $value) {
				$savePath[] = uploads($value);

                // $savePath = $savePath[0]
              //判断是否是ajax发送的请求
      //  if(!empty($_SERVER['HTTP_X_REQUESTED_WITH'])){

	     // echo json_encode($savePath);die;
      //  }

			}
     		
	}

//图片上传函数结束-------------------------------------

    ##回调方法
     
    $img_url = $savePath[0];

    $img_url = substr($img_url,12);
	echo "
    <script>
    window.parent.document.getElementById('newsurl').value='{$img_url}';
    window.parent.document.getElementById('success').style='display:block';
    </script>
    ";
}



?>